package cn.edu.Controller.servlet;//package cn.edu.Controller.servlet;
//
//import javax.servlet.*;
//import javax.servlet.annotation.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//
//@WebFilter(filterName = "FirstFilter")
//public class FirstFilter implements Filter {
//    public void init(FilterConfig config) throws ServletException {
//    }
//
//    public void destroy() {
//    }
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
//        HttpServletRequest httpRequest = (HttpServletRequest) request;
//        HttpServletResponse httpResponse = (HttpServletResponse) response;
//        String uri = httpRequest.getRequestURI();
//        HttpSession session = httpRequest.getSession();
//        Object username = session.getAttribute("username");
//        if(uri.contains("/login")||uri.contains("/admin")||uri.contains("/static")){
//            chain.doFilter(request, response);
//        }
//        else {
//            request.setAttribute("login_msg", "您还未登录");
//            request.getRequestDispatcher("/login").forward(request, response);
//        }
//
//    }
//}
